package vtt.android.cartoon_video.activities;

import vtt.android.cartoon_video.BaseApplication;
import vtt.android.cartoon_video.R;
import vtt.android.library.activities.VttSwipeBackLayoutActivity;
import vtt.android.library.swipebacklayout.SwipeBackLayout;
import vtt.android.library.swipebacklayout.SwipeBackLayout.SwipeListener;
import vtt.android.library.utils.VttGA;
import android.os.Bundle;

public class BaseSwipeBackActivity extends VttSwipeBackLayoutActivity {

    protected SwipeBackLayout mSwipeBackLayout;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initActionBar();
        // setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        
        mSwipeBackLayout = getSwipeBackLayout();
        mSwipeBackLayout.setEdgeTrackingEnabled(SwipeBackLayout.EDGE_LEFT);
        
        mSwipeBackLayout.addSwipeListener(new SwipeListener() {
            @Override
            public void onScrollStateChange(int state, float scrollPercent) {
                log.d("VTT>>> onScrollStateChange state " + state + "; scrollPercent " + scrollPercent);
            }
            
            @Override
            public void onScrollOverThreshold() {
                //log.d("VTT>>> onScrollOverThreshold close activity");
                VttGA.sendEvent(mContext, "Swipe Back", "Swipe Back", "", 0);
            }
            
            @Override
            public void onEdgeTouch(int edgeFlag) {
                //log.d("VTT>>> onEdgeTouch");
            }
        });
    }

    protected void initActionBar() {
        actionBar = getSupportActionBar();
        actionBar.setDisplayUseLogoEnabled(false);
        actionBar.setDisplayShowHomeEnabled(false);
    }

    @Override
    protected void onResume() {
        super.onResume();
        log.d("VTT>>> " + "onResume");
        BaseApplication.mIsMainActivityRunning = true;
    }
    
    @Override
    protected void onStop() {
        super.onStop();
        log.d("VTT>>> " + "onStop");
        BaseApplication.mIsMainActivityRunning = false;
    }
}
